﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Streaming_Service.User {
    using System.Runtime.Serialization;

    [DataContract]
    public class UserEntry {
        // Id of the user.
        [DataMember]
        public int Id { get; set; }

        // The name of the user.
        [DataMember]
        public string Name { get; set; }

        // The email of the user.
        [DataMember]
        public string Email { get; set; }

        // The birthday of the user.
        [DataMember]
        public DateTime? Birthday { get; set; }

        // Is the user admin?
        [DataMember]
        public bool IsAdmin { get; set; }

        public UserEntry() {
            Id = -1;
            Name = null;
            Email = null;
            Birthday = null;
            IsAdmin = false;
        }

        public static bool IsValidBirthday(DateTime? birthday) {
            if (birthday == null) return false;
            var ts = (DateTime.Now - birthday.Value);
            return ts.TotalDays >= 365 * 13 && ts.TotalDays <= 365 * 120;
        }
    }
}